home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3
/
CHAPTE20
/
EX1.C
next >
Wrap
C/C++ Source or Header
|
1995-03-19
|
2KB
|
52 lines
#include <genstub.c>
// WndProc Window message procedure
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch (uMsg) // Process Windows messages.
{
case WM_COMMAND: // Process the menu items.
switch ( LOWORD( wParam ) )
{
case IDM_TEST: // Write the tick count to the INI file
{
TCHAR szBuffer[128];
wsprintf( szBuffer, "%ld", GetTickCount() );
WritePrivateProfileString( "TestSection", // Section Name.
"Ticks", // Key Name.
szBuffer, // Key Value.
"YOUR.INI" ); // INI File Name
InvalidateRect( hWnd, NULL, TRUE );
UpdateWindow( hWnd );
}
break;
case IDM_EXIT:
DestroyWindow( hWnd );
break;
}
break;
case WM_PAINT:
{ // Display contents of Ticks key.
PAINTSTRUCT ps;
TCHAR szBuffer[128];
BeginPaint( hWnd, &ps );
wsprintf( szBuffer, "Current Tick Key's Value: %8lu",
GetPrivateProfileInt( "TestSection", // Section Name
"Ticks", // Key Name
0, // Default Value
"YOUR.INI" ) ); // INI File Name
TextOut( ps.hdc, 0, 0, szBuffer, lstrlen( szBuffer ) );
EndPaint( hWnd, &ps );
}
break ;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
return( 0L );
}
#include <about.c>